/**
 * 
 */
package com.googolmo.NowPlaying;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

/**
 * @author user
 * 
 */
public class MusicNotification {

	private static NotificationManager nm;
	private static Notification notification;
	private static final int mNumber = 0;

	public static void setNofication(Context context, String description,
			String subject, String text) {
		// try {
		nm = (NotificationManager) context
				.getSystemService(Context.NOTIFICATION_SERVICE);
		notification = new Notification(R.drawable.ic_stat_np,
				context.getString(R.string.app_name),
				System.currentTimeMillis());

		Intent pIntent = new Intent(Intent.ACTION_MAIN);
		pIntent.setAction("android.intent.action.SEND");
		pIntent.addCategory(Intent.CATEGORY_DEFAULT);
		pIntent.setType("text/plain");
		// pIntent.putExtra(name, value)

		pIntent.putExtra(android.content.Intent.EXTRA_TEXT, text);
		pIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
		pIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
				pIntent, PendingIntent.FLAG_UPDATE_CURRENT);
		notification.setLatestEventInfo(context,
				context.getString(R.string.app_name), description,
				pendingIntent);
		nm.notify(mNumber, notification);
		// } catch (Exception e) {
		// nm = null;
		// Log.e("NowPlaying", e.getLocalizedMessage());
		// }
	}

	public static void deleteNotification(Context context) {
		nm = (NotificationManager) context
				.getSystemService(Context.NOTIFICATION_SERVICE);
		nm.cancel(mNumber);
	}
}
